import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { ApplicationModule } from './app.module';

async function bootstrap() {

  // 设置cors允许跨域访问
  const appOptions = {cors: true};
  const app = await NestFactory.create(ApplicationModule, appOptions);
  // 设置所有api前缀
  app.setGlobalPrefix('api');

  // 设置swagger参数
  const options = new DocumentBuilder()
    .setTitle('GrowCms App')
    .setDescription('GrowCms API 文档')
    .setVersion('1.0')
    .setBasePath('api')
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app, options);
  // 设置swagger网址
  SwaggerModule.setup('docs', app, document);

  await app.listen(3000);
}
bootstrap();
